<template>
  <h1>{{ title }}</h1>
  <button @click="get">改变标题</button>
  <p v-if="currentTime">当前时间: {{ currentTime }}</p>
</template>

<script setup>
import { ref } from 'vue';
const title = ref('初始标题');
const currentTime = ref('')
function showCurrentTime () {
  const now = new Date();
  currentTime.value = now.toLocaleString();
}
function get () {
  title.value = '欢迎来到我的网站';
  showCurrentTime();
}
</script>

<style scoped></style>